﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ShareMarking.Entity;
using ShareMarking.Service;
using System.Text;

namespace ShareMarking.ShowqrCode
{
    public partial class showecp : System.Web.UI.Page
    {
        public string nccode = "";
        public string code_url = "";     
        protected void Page_Load(object sender, EventArgs e)
        {
            nccode = ComLib.QueryStringHelper.GetFormString("nccode");
            if (nccode == "")
            {
                ComLib.LogLib.Log4NetBase.Log("1、请求异常-NC_Code为空。时间:"+DateTime.Now.ToString());
                return;
            }
            shownc(nccode);
        }
        /// <summary>
        /// 根据NC_Code获取二维码
        /// </summary>
        private void shownc(string nccode)
        {
            nc_ncuser nc = nc_ncuserService.Instance.Get_SingleEntity_byWhere(nc_ncuser._.nc_code == nccode);
            if (nc != null)
            {
                #region 查找妈妈班二维码qr_Type == 1006
                qr_QrCodeRelate relate = qr_QrCodeRelateService.Instance.Get_SingleEntity_byWhere(
                   qr_QrCodeRelate._.qr_Type == 1006 && qr_QrCodeRelate._.rel_Code == nccode && qr_QrCodeRelate._.IsDelete == false);
                if (relate != null)
                {
                    qr_QrCode qr = qr_QrCodeService.Instance.Get_SingleEntity_byWhere(qr_QrCode._.scene_id == relate.qr_Scene_ID);
                    if (qr != null)
                    {
                        code_url = qr.qrcode_url;
                    }
                    else
                    {
                        ComLib.LogLib.Log4NetBase.Log("4、请求异常-NC_Code没有二维码。NC_Code=" + nccode + "/时间:" + DateTime.Now.ToString());
                    }
                }
                else
                {
                    ComLib.LogLib.Log4NetBase.Log("3、请求异常-NC_Code没有关联码。NC_Code=" + nccode + "/时间:" + DateTime.Now.ToString());
                }
                #endregion
            }
            else
            {
                ComLib.LogLib.Log4NetBase.Log("2、请求异常-NC_Code不存在。NC_Code=" + nccode + "/时间:" + DateTime.Now.ToString());
            }
        }
    }
}